#ifndef YPIPI_MUMUPI0PI0ROW_HPP_
#define YPIPI_MUMUPI0PI0ROW_HPP_

#include <vector>

#include <hdf5.h>

struct ypipi_mumupi0pi0row_t {
  public:
    float beam_e;
    int best_chi2;
    int eventno;
    int expno;
    long gggg_idhash;
    float m2_off_pi01;
    float m2_off_pi02;
    float m_mumu;
    float m_mumupi0pi0;
    float m_pi0pi0;
    float mbc_mumupi0pi0;
    float missing_e;
    float missing_px;
    float missing_py;
    float missing_pz;
    float mm_off_mumu;
    float mm_off_pi0pi0;
    float mum_e;
    float mum_muid_llh;
    float mum_muon_vs_electron_llh;
    float mum_muon_vs_kaon_llh;
    float mum_pion_vs_kaon_llh;
    float mum_px;
    float mum_py;
    float mum_pz;
    long mumupi0pi0_idhash;
    float mup_e;
    float mup_muid_llh;
    float mup_muon_vs_electron_llh;
    float mup_muon_vs_kaon_llh;
    float mup_pion_vs_kaon_llh;
    float mup_px;
    float mup_py;
    float mup_pz;
    int n_pi0pi0_combos;
    int n_pm_combos;
    float p_total_cm;
    float pi01_chisq;
    float pi01_e;
    float pi01_g1e;
    float pi01_g1e9oe25;
    float pi01_g1theta_lab;
    float pi01_g2e;
    float pi01_g2e9oe25;
    float pi01_g2theta_lab;
    float pi01_m;
    float pi01_px;
    float pi01_py;
    float pi01_pz;
    float pi02_chisq;
    float pi02_e;
    float pi02_g1e;
    float pi02_g1e9oe25;
    float pi02_g1theta_lab;
    float pi02_g2e;
    float pi02_g2e9oe25;
    float pi02_g2theta_lab;
    float pi02_m;
    float pi02_px;
    float pi02_py;
    float pi02_pz;
    float r2;
    int runno;
    int shares_photons;

    static std::vector<hid_t> field_types() {
      static std::vector<hid_t> types;

      if (types.size() == 0) {
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_INT);
        types.push_back(H5T_NATIVE_INT);
        types.push_back(H5T_NATIVE_INT);
        types.push_back(H5T_NATIVE_LONG);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_LONG);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_INT);
        types.push_back(H5T_NATIVE_INT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_FLOAT);
        types.push_back(H5T_NATIVE_INT);
        types.push_back(H5T_NATIVE_INT);
      }

      return types;
    }

    static std::vector<std::string> field_names() {
      static std::vector<std::string> fields;

      if (fields.size() == 0) {
        fields.push_back("beam_e");
        fields.push_back("best_chi2");
        fields.push_back("eventno");
        fields.push_back("expno");
        fields.push_back("gggg_idhash");
        fields.push_back("m2_off_pi01");
        fields.push_back("m2_off_pi02");
        fields.push_back("m_mumu");
        fields.push_back("m_mumupi0pi0");
        fields.push_back("m_pi0pi0");
        fields.push_back("mbc_mumupi0pi0");
        fields.push_back("missing_e");
        fields.push_back("missing_px");
        fields.push_back("missing_py");
        fields.push_back("missing_pz");
        fields.push_back("mm_off_mumu");
        fields.push_back("mm_off_pi0pi0");
        fields.push_back("mum_e");
        fields.push_back("mum_muid_llh");
        fields.push_back("mum_muon_vs_electron_llh");
        fields.push_back("mum_muon_vs_kaon_llh");
        fields.push_back("mum_pion_vs_kaon_llh");
        fields.push_back("mum_px");
        fields.push_back("mum_py");
        fields.push_back("mum_pz");
        fields.push_back("mumupi0pi0_idhash");
        fields.push_back("mup_e");
        fields.push_back("mup_muid_llh");
        fields.push_back("mup_muon_vs_electron_llh");
        fields.push_back("mup_muon_vs_kaon_llh");
        fields.push_back("mup_pion_vs_kaon_llh");
        fields.push_back("mup_px");
        fields.push_back("mup_py");
        fields.push_back("mup_pz");
        fields.push_back("n_pi0pi0_combos");
        fields.push_back("n_pm_combos");
        fields.push_back("p_total_cm");
        fields.push_back("pi01_chisq");
        fields.push_back("pi01_e");
        fields.push_back("pi01_g1e");
        fields.push_back("pi01_g1e9oe25");
        fields.push_back("pi01_g1theta_lab");
        fields.push_back("pi01_g2e");
        fields.push_back("pi01_g2e9oe25");
        fields.push_back("pi01_g2theta_lab");
        fields.push_back("pi01_m");
        fields.push_back("pi01_px");
        fields.push_back("pi01_py");
        fields.push_back("pi01_pz");
        fields.push_back("pi02_chisq");
        fields.push_back("pi02_e");
        fields.push_back("pi02_g1e");
        fields.push_back("pi02_g1e9oe25");
        fields.push_back("pi02_g1theta_lab");
        fields.push_back("pi02_g2e");
        fields.push_back("pi02_g2e9oe25");
        fields.push_back("pi02_g2theta_lab");
        fields.push_back("pi02_m");
        fields.push_back("pi02_px");
        fields.push_back("pi02_py");
        fields.push_back("pi02_pz");
        fields.push_back("r2");
        fields.push_back("runno");
        fields.push_back("shares_photons");
      }

      return fields;
    }

    static hid_t h5_type() {
      static hid_t type_id = 0;

      if (type_id == 0) {
        type_id = H5Tcreate(H5T_COMPOUND, sizeof(ypipi_mumupi0pi0row_t));

        H5Tinsert(type_id, "beam_e", HOFFSET(ypipi_mumupi0pi0row_t, beam_e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "best_chi2", HOFFSET(ypipi_mumupi0pi0row_t, best_chi2), H5T_NATIVE_INT);
        H5Tinsert(type_id, "eventno", HOFFSET(ypipi_mumupi0pi0row_t, eventno), H5T_NATIVE_INT);
        H5Tinsert(type_id, "expno", HOFFSET(ypipi_mumupi0pi0row_t, expno), H5T_NATIVE_INT);
        H5Tinsert(type_id, "gggg_idhash", HOFFSET(ypipi_mumupi0pi0row_t, gggg_idhash), H5T_NATIVE_LONG);
        H5Tinsert(type_id, "m2_off_pi01", HOFFSET(ypipi_mumupi0pi0row_t, m2_off_pi01), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "m2_off_pi02", HOFFSET(ypipi_mumupi0pi0row_t, m2_off_pi02), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "m_mumu", HOFFSET(ypipi_mumupi0pi0row_t, m_mumu), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "m_mumupi0pi0", HOFFSET(ypipi_mumupi0pi0row_t, m_mumupi0pi0), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "m_pi0pi0", HOFFSET(ypipi_mumupi0pi0row_t, m_pi0pi0), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mbc_mumupi0pi0", HOFFSET(ypipi_mumupi0pi0row_t, mbc_mumupi0pi0), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "missing_e", HOFFSET(ypipi_mumupi0pi0row_t, missing_e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "missing_px", HOFFSET(ypipi_mumupi0pi0row_t, missing_px), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "missing_py", HOFFSET(ypipi_mumupi0pi0row_t, missing_py), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "missing_pz", HOFFSET(ypipi_mumupi0pi0row_t, missing_pz), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mm_off_mumu", HOFFSET(ypipi_mumupi0pi0row_t, mm_off_mumu), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mm_off_pi0pi0", HOFFSET(ypipi_mumupi0pi0row_t, mm_off_pi0pi0), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mum_e", HOFFSET(ypipi_mumupi0pi0row_t, mum_e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mum_muid_llh", HOFFSET(ypipi_mumupi0pi0row_t, mum_muid_llh), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mum_muon_vs_electron_llh", HOFFSET(ypipi_mumupi0pi0row_t, mum_muon_vs_electron_llh), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mum_muon_vs_kaon_llh", HOFFSET(ypipi_mumupi0pi0row_t, mum_muon_vs_kaon_llh), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mum_pion_vs_kaon_llh", HOFFSET(ypipi_mumupi0pi0row_t, mum_pion_vs_kaon_llh), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mum_px", HOFFSET(ypipi_mumupi0pi0row_t, mum_px), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mum_py", HOFFSET(ypipi_mumupi0pi0row_t, mum_py), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mum_pz", HOFFSET(ypipi_mumupi0pi0row_t, mum_pz), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mumupi0pi0_idhash", HOFFSET(ypipi_mumupi0pi0row_t, mumupi0pi0_idhash), H5T_NATIVE_LONG);
        H5Tinsert(type_id, "mup_e", HOFFSET(ypipi_mumupi0pi0row_t, mup_e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mup_muid_llh", HOFFSET(ypipi_mumupi0pi0row_t, mup_muid_llh), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mup_muon_vs_electron_llh", HOFFSET(ypipi_mumupi0pi0row_t, mup_muon_vs_electron_llh), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mup_muon_vs_kaon_llh", HOFFSET(ypipi_mumupi0pi0row_t, mup_muon_vs_kaon_llh), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mup_pion_vs_kaon_llh", HOFFSET(ypipi_mumupi0pi0row_t, mup_pion_vs_kaon_llh), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mup_px", HOFFSET(ypipi_mumupi0pi0row_t, mup_px), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mup_py", HOFFSET(ypipi_mumupi0pi0row_t, mup_py), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "mup_pz", HOFFSET(ypipi_mumupi0pi0row_t, mup_pz), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "n_pi0pi0_combos", HOFFSET(ypipi_mumupi0pi0row_t, n_pi0pi0_combos), H5T_NATIVE_INT);
        H5Tinsert(type_id, "n_pm_combos", HOFFSET(ypipi_mumupi0pi0row_t, n_pm_combos), H5T_NATIVE_INT);
        H5Tinsert(type_id, "p_total_cm", HOFFSET(ypipi_mumupi0pi0row_t, p_total_cm), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_chisq", HOFFSET(ypipi_mumupi0pi0row_t, pi01_chisq), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_e", HOFFSET(ypipi_mumupi0pi0row_t, pi01_e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_g1e", HOFFSET(ypipi_mumupi0pi0row_t, pi01_g1e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_g1e9oe25", HOFFSET(ypipi_mumupi0pi0row_t, pi01_g1e9oe25), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_g1theta_lab", HOFFSET(ypipi_mumupi0pi0row_t, pi01_g1theta_lab), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_g2e", HOFFSET(ypipi_mumupi0pi0row_t, pi01_g2e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_g2e9oe25", HOFFSET(ypipi_mumupi0pi0row_t, pi01_g2e9oe25), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_g2theta_lab", HOFFSET(ypipi_mumupi0pi0row_t, pi01_g2theta_lab), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_m", HOFFSET(ypipi_mumupi0pi0row_t, pi01_m), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_px", HOFFSET(ypipi_mumupi0pi0row_t, pi01_px), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_py", HOFFSET(ypipi_mumupi0pi0row_t, pi01_py), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi01_pz", HOFFSET(ypipi_mumupi0pi0row_t, pi01_pz), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_chisq", HOFFSET(ypipi_mumupi0pi0row_t, pi02_chisq), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_e", HOFFSET(ypipi_mumupi0pi0row_t, pi02_e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_g1e", HOFFSET(ypipi_mumupi0pi0row_t, pi02_g1e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_g1e9oe25", HOFFSET(ypipi_mumupi0pi0row_t, pi02_g1e9oe25), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_g1theta_lab", HOFFSET(ypipi_mumupi0pi0row_t, pi02_g1theta_lab), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_g2e", HOFFSET(ypipi_mumupi0pi0row_t, pi02_g2e), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_g2e9oe25", HOFFSET(ypipi_mumupi0pi0row_t, pi02_g2e9oe25), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_g2theta_lab", HOFFSET(ypipi_mumupi0pi0row_t, pi02_g2theta_lab), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_m", HOFFSET(ypipi_mumupi0pi0row_t, pi02_m), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_px", HOFFSET(ypipi_mumupi0pi0row_t, pi02_px), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_py", HOFFSET(ypipi_mumupi0pi0row_t, pi02_py), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "pi02_pz", HOFFSET(ypipi_mumupi0pi0row_t, pi02_pz), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "r2", HOFFSET(ypipi_mumupi0pi0row_t, r2), H5T_NATIVE_FLOAT);
        H5Tinsert(type_id, "runno", HOFFSET(ypipi_mumupi0pi0row_t, runno), H5T_NATIVE_INT);
        H5Tinsert(type_id, "shares_photons", HOFFSET(ypipi_mumupi0pi0row_t, shares_photons), H5T_NATIVE_INT);
      }

      return type_id;
    }

    static const char* hbook_defstr() {
      return "beam_e best_chi2 eventno\
              expno gggg_idhash m2_off_pi01\
              m2_off_pi02 m_mumu m_mumupi0pi0\
              m_pi0pi0 mbc_mumupi0pi0 missing_e\
              missing_px missing_py missing_pz\
              mm_off_mumu mm_off_pi0pi0 mum_e\
              mum_muid_llh mum_muon_vs_electron_llh mum_muon_vs_kaon_llh\
              mum_pion_vs_kaon_llh mum_px mum_py\
              mum_pz mumupi0pi0_idhash mup_e\
              mup_muid_llh mup_muon_vs_electron_llh mup_muon_vs_kaon_llh\
              mup_pion_vs_kaon_llh mup_px mup_py\
              mup_pz n_pi0pi0_combos n_pm_combos\
              p_total_cm pi01_chisq pi01_e\
              pi01_g1e pi01_g1e9oe25 pi01_g1theta_lab\
              pi01_g2e pi01_g2e9oe25 pi01_g2theta_lab\
              pi01_m pi01_px pi01_py\
              pi01_pz pi02_chisq pi02_e\
              pi02_g1e pi02_g1e9oe25 pi02_g1theta_lab\
              pi02_g2e pi02_g2e9oe25 pi02_g2theta_lab\
              pi02_m pi02_px pi02_py\
              pi02_pz r2 runno\
              shares_photons";
    }

};

#endif //YPIPI_MUMUPI0PI0ROW_HPP_
